<template>
  <InlineLayout title-name="原始单位信息列表">
    <template #header>
      <my-form ref="queryFormRef" v-model:modelValue="queryParams" :model="queryParams" :items-datas="itemsDatas">
        <my-button type="reset" title="重置" @click="resetQuery" />
        <my-button type="search" title="查询" :loading="loading" @click="handleQuery" />
      </my-form>
    </template>

    <!-- <template #titleTools>
      <my-button v-hasPermi="['yuanshidian:ab01:add']" type="add" title="单位新增" @click="handleAdd" />
      <my-button v-hasPermi="['yuanshidian:ab01:export']" type="export" title="单位导出" @click="handleExport" />
    </template> -->

    <my-table :columns="columns" :table-data="tableData">
      <template #operation="scope">
        <el-button link type="primary" @click="handleDetail(scope.row)">详情</el-button>
      </template>
    </my-table>
    <template #footer>
      <pagination v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
    </template>
  </InlineLayout>
  <addOrEdit v-model="dialog.visible" :dialog-title="dialog.title" :current-row="currentRow" />
</template>

<script setup name="Ab01" lang="ts">
import { listAb01 } from '@/api/yuanshidian/ab01';
import { Ab01VO, Ab01Query, Ab01Form } from '@/api/yuanshidian/ab01/types';
import addOrEdit from '@/views/yuanshidian/ab01/components/addOrEdit.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;

const loading = ref(true);
const showSearch = ref(true);
const total = ref(0);
const currentRow = ref({});
const queryFormRef = ref<ElFormInstance>();

const dialog = reactive<DialogOption>({
  visible: false,
  auditIsShow: false,
  title: '',
  isShow: false
});
const data = reactive<PageData<Ab01Form, Ab01Query>>({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    dw01: '',
    delStatus: 0,
    dw02: ''
  }
});
const state = reactive({
  itemsDatas: [
    { label: '单位编码', prop: 'dw01', type: 'input' },
    { label: '单位名称', prop: 'dw02', type: 'input' }
  ],
  tableData: [],
  columns: [
    { label: '序号', type: 'index', width: '55', prop: 'index' },
    { label: '统筹区编码', prop: 'aaa027', align: 'center', width: '150' },
    { label: '单位编码', prop: 'dw01', align: 'center', width: '150' },
    { label: '单位名称', prop: 'dw02', align: 'center' },
    { label: '详细地址', prop: 'dw04', align: 'center' },
    { label: '单位开户行', prop: 'dw08', align: 'center' },
    { label: '单位法人', prop: 'dw10', align: 'center', width: '80' },
    { label: '单位联系人', prop: 'dw12', align: 'center', width: '150' },
    { label: '操作', type: 'operation', minWidth: '80px' }
  ]
});
const { itemsDatas, tableData, columns, dataForm } = toRefs(state);
const { queryParams } = toRefs(data);

/** 查询原单位信息列表 */
const getList = async () => {
  loading.value = true;
  const res = await listAb01(queryParams.value);
  tableData.value = res.rows;
  total.value = res.total;
  loading.value = false;
};

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
};

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value?.resetFields();
  handleQuery();
};
/** 查看详情 */
const handleDetail = (row) => {
  currentRow.value.id = row.id;
  currentRow.value.type = 'detail';
  dialog.title = '查看原单位信息';
  dialog.visible = true;
};
//对比
const handleContrast = (row) => {
  currentRow.value.id = row.id;
  dialog.isShow = true;
};
onMounted(() => {
  getList();
});
</script>
